{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "e99d863c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "def quarterly_to_annual_avg(quarterly_data):\n",
    "    \"\"\"\n",
    "    此函数用于将季度数据转换为年度平均值。\n",
    "    :param quarterly_data: 包含季度数据的 Pandas Series，索引为日期。\n",
    "    :return: 包含年度平均值的 Pandas Series，索引为年份。\n",
    "    \"\"\"\n",
    "    # 将索引转换为日期时间类型\n",
    "    quarterly_data.index = pd.to_datetime(quarterly_data.index)\n",
    "    # 按年份分组并计算平均值\n",
    "    annual_avg = quarterly_data.groupby(quarterly_data.index.year).mean()\n",
    "    return annual_avg\n",
    "\n",
    "def ratio_of_series(series1, series2):\n",
    "    \"\"\"\n",
    "    此函数用于计算两个序列对应元素之比，仅保留它们索引的公共部分。\n",
    "    \n",
    "    参数:\n",
    "    series1 (pd.Series): 第一个序列。\n",
    "    series2 (pd.Series): 第二个序列。\n",
    "    \n",
    "    返回:\n",
    "    pd.Series: 包含两个序列索引公共部分的对应元素之比的序列。\n",
    "    \"\"\"\n",
    "    # 找出两个序列索引的公共部分\n",
    "    common_index = series1.index.intersection(series2.index)\n",
    "    # 筛选出公共索引部分的数据\n",
    "    series1_common = series1.loc[common_index]\n",
    "    series2_common = series2.loc[common_index]\n",
    "    # 计算两个序列对应元素之比\n",
    "    ratio = series1_common / series2_common\n",
    "    return ratio\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "eef20aeb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import plotly.graph_objects as go"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89182433",
   "metadata": {},
   "source": [
    "# 美国GDP数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "7368783d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys(['README', 'Quarterly'])\n",
      "dict_keys(['README', 'Monthly'])\n"
     ]
    }
   ],
   "source": [
    "df = pd.read_excel(\"data/USA/GDP.xlsx\", sheet_name=None)\n",
    "df_dpi = pd.read_excel(\"data/USA/DSPI.xlsx\", sheet_name=None)\n",
    "print(df.keys())\n",
    "print(df_dpi.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "e6e7bc54",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "observation_date\n",
       "1947      249.61550\n",
       "1948      274.46775\n",
       "1949      272.47525\n",
       "1950      299.82725\n",
       "1951      346.91325\n",
       "           ...     \n",
       "2020    21354.10475\n",
       "2021    23681.17075\n",
       "2022    26006.89250\n",
       "2023    27720.70950\n",
       "2024    29183.83600\n",
       "Name: GDP, Length: 78, dtype: float64"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "us_gdp_data = df['Quarterly']\n",
    "us_gdp_data.index = us_gdp_data['observation_date']\n",
    "us_gdp_data = us_gdp_data['GDP']\n",
    "us_gdp_year = quarterly_to_annual_avg(us_gdp_data)\n",
    "us_gdp_year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "48a83f5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "observation_date\n",
       "1959      360.575000\n",
       "1960      376.066667\n",
       "1961      393.316667\n",
       "1962      417.291667\n",
       "1963      438.216667\n",
       "            ...     \n",
       "2021    18714.400000\n",
       "2022    18844.016667\n",
       "2023    20546.808333\n",
       "2024    21634.483333\n",
       "2025    22209.800000\n",
       "Name: DSPI, Length: 67, dtype: float64"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "us_dpi_data = df_dpi['Monthly']\n",
    "us_dpi_data.index = us_dpi_data['observation_date']\n",
    "us_dpi_data = us_dpi_data['DSPI']\n",
    "us_dpi_year = quarterly_to_annual_avg(us_dpi_data)\n",
    "us_dpi_year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "65ee3f7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "observation_date\n",
       "1959    0.691215\n",
       "1960    0.693361\n",
       "1961    0.699591\n",
       "1962    0.690970\n",
       "1963    0.687451\n",
       "          ...   \n",
       "2020    0.813652\n",
       "2021    0.790265\n",
       "2022    0.724578\n",
       "2023    0.741208\n",
       "2024    0.741317\n",
       "Length: 66, dtype: float64"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_dpi_gdp = ratio_of_series(us_dpi_year, us_gdp_year)\n",
    "ratio_dpi_gdp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "09b99a81",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "text": [
          "0.69",
          "0.69",
          "0.70",
          "0.69",
          "0.69",
          "0.70",
          "0.69",
          "0.68",
          "0.69",
          "0.68",
          "0.68",
          "0.71",
          "0.71",
          "0.70",
          "0.71",
          "0.71",
          "0.73",
          "0.71",
          "0.70",
          "0.69",
          "0.69",
          "0.71",
          "0.70",
          "0.73",
          "0.72",
          "0.72",
          "0.72",
          "0.72",
          "0.71",
          "0.72",
          "0.72",
          "0.72",
          "0.73",
          "0.74",
          "0.73",
          "0.72",
          "0.72",
          "0.72",
          "0.72",
          "0.72",
          "0.71",
          "0.72",
          "0.73",
          "0.74",
          "0.74",
          "0.73",
          "0.72",
          "0.72",
          "0.72",
          "0.74",
          "0.75",
          "0.75",
          "0.76",
          "0.76",
          "0.73",
          "0.74",
          "0.74",
          "0.74",
          "0.75",
          "0.75",
          "0.75",
          "0.81",
          "0.79",
          "0.72",
          "0.74",
          "0.74"
         ],
         "textposition": "auto",
         "type": "bar",
         "x": [
          1959,
          1960,
          1961,
          1962,
          1963,
          1964,
          1965,
          1966,
          1967,
          1968,
          1969,
          1970,
          1971,
          1972,
          1973,
          1974,
          1975,
          1976,
          1977,
          1978,
          1979,
          1980,
          1981,
          1982,
          1983,
          1984,
          1985,
          1986,
          1987,
          1988,
          1989,
          1990,
          1991,
          1992,
          1993,
          1994,
          1995,
          1996,
          1997,
          1998,
          1999,
          2000,
          2001,
          2002,
          2003,
          2004,
          2005,
          2006,
          2007,
          2008,
          2009,
          2010,
          2011,
          2012,
          2013,
          2014,
          2015,
          2016,
          2017,
          2018,
          2019,
          2020,
          2021,
          2022,
          2023,
          2024
         ],
         "y": [
          0.6912145352980446,
          0.6933609399398056,
          0.6995906183887182,
          0.6909700460517909,
          0.6874509930036508,
          0.6955954912487164,
          0.6911043220626971,
          0.6810187312422491,
          0.6892889415401462,
          0.6845557815821353,
          0.6837965897384244,
          0.7099296988150213,
          0.7134682677601412,
          0.7042646252504341,
          0.7074449127809084,
          0.7123639169903752,
          0.7251348493436326,
          0.7099210665029726,
          0.7019642220967982,
          0.6948747811107939,
          0.6903596384347014,
          0.7086914136152956,
          0.7038964653167462,
          0.7281310168296841,
          0.7233921104901763,
          0.7209084375078945,
          0.7156231746144055,
          0.7191352144522514,
          0.7120657773653921,
          0.7207348455826906,
          0.7184660489732234,
          0.7242194114195958,
          0.7309064951286409,
          0.7368789145769741,
          0.7296115259982594,
          0.7201403897531434,
          0.7244914920909653,
          0.7220379155064767,
          0.7160715911288992,
          0.7233862106575936,
          0.7129644773839002,
          0.7204176418606454,
          0.7327673117695901,
          0.7409456302164451,
          0.7400387586631152,
          0.733977080351411,
          0.7158147852202862,
          0.7198423451740448,
          0.7212572848737736,
          0.7392198508560854,
          0.7537815518849729,
          0.7521455564414782,
          0.7600050680359467,
          0.7634006748300055,
          0.7340475984584331,
          0.7382041085462286,
          0.7397022471890664,
          0.740704471653616,
          0.7451478833881612,
          0.7481432835723592,
          0.7504412975780257,
          0.813651529924241,
          0.7902649829928698,
          0.7245777890098429,
          0.7412078804596735,
          0.7413173283091823
         ]
        }
       ],
       "layout": {
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "示例柱状图"
        },
        "xaxis": {
         "title": {
          "text": "类别"
         }
        },
        "yaxis": {
         "title": {
          "text": "数值"
         }
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ratio_dpi_gdp = ratio_of_series(us_dpi_year, us_gdp_year)\n",
    "# 创建一个 Plotly 的折线图\n",
    "# 创建柱状图\n",
    "fig = go.Figure(data=[go.Bar(\n",
    "    x=ratio_dpi_gdp.index,\n",
    "    y=ratio_dpi_gdp.values,\n",
    "    text=[f\"{s:.2f}\" for s in ratio_dpi_gdp.values],  # 显示数值在柱子上\n",
    "    textposition='auto'\n",
    ")])\n",
    "\n",
    "# 设置图表标题和坐标轴标签\n",
    "fig.update_layout(\n",
    "    title='示例柱状图',\n",
    "    xaxis_title='类别',\n",
    "    yaxis_title='数值'\n",
    ")\n",
    "\n",
    "# 显示图表\n",
    "fig"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "56a79097",
   "metadata": {},
   "source": [
    "# 中国GDP和可支配收入数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dbff6575",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "3aac07d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>可支配收入_住户部门</th>\n",
       "      <th>增加值_国内合计</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1992-12-31</th>\n",
       "      <td>18569.157304</td>\n",
       "      <td>2.663810e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1993-12-31</th>\n",
       "      <td>22916.033830</td>\n",
       "      <td>3.463440e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1994-12-31</th>\n",
       "      <td>32220.436853</td>\n",
       "      <td>4.675940e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995-12-31</th>\n",
       "      <td>39863.656425</td>\n",
       "      <td>5.847810e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1996-12-31</th>\n",
       "      <td>48650.470450</td>\n",
       "      <td>6.788460e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1997-12-31</th>\n",
       "      <td>53411.442745</td>\n",
       "      <td>7.446260e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1998-12-31</th>\n",
       "      <td>56728.456581</td>\n",
       "      <td>7.834520e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999-12-31</th>\n",
       "      <td>58768.622894</td>\n",
       "      <td>8.206750e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-12-31</th>\n",
       "      <td>64764.455546</td>\n",
       "      <td>9.921460e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-12-31</th>\n",
       "      <td>69691.308729</td>\n",
       "      <td>1.096552e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2002-12-31</th>\n",
       "      <td>75015.702228</td>\n",
       "      <td>1.203327e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-12-31</th>\n",
       "      <td>83012.318353</td>\n",
       "      <td>1.358228e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004-12-31</th>\n",
       "      <td>94545.642409</td>\n",
       "      <td>1.598783e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005-12-31</th>\n",
       "      <td>107217.032571</td>\n",
       "      <td>1.849374e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006-12-31</th>\n",
       "      <td>125117.580960</td>\n",
       "      <td>2.163144e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007-12-31</th>\n",
       "      <td>152265.316522</td>\n",
       "      <td>2.658103e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008-12-31</th>\n",
       "      <td>179880.320355</td>\n",
       "      <td>3.140454e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009-12-31</th>\n",
       "      <td>197488.316843</td>\n",
       "      <td>3.409028e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-12-31</th>\n",
       "      <td>229965.430370</td>\n",
       "      <td>4.015128e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-12-31</th>\n",
       "      <td>274930.226704</td>\n",
       "      <td>4.731041e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-12-31</th>\n",
       "      <td>308344.771021</td>\n",
       "      <td>5.194701e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-12-31</th>\n",
       "      <td>341749.705414</td>\n",
       "      <td>5.880188e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-12-31</th>\n",
       "      <td>373626.512522</td>\n",
       "      <td>6.439741e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-12-31</th>\n",
       "      <td>404897.471129</td>\n",
       "      <td>6.890521e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-12-31</th>\n",
       "      <td>441165.522969</td>\n",
       "      <td>7.435855e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31</th>\n",
       "      <td>489176.864283</td>\n",
       "      <td>8.207543e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-31</th>\n",
       "      <td>543300.943681</td>\n",
       "      <td>9.192811e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-12-31</th>\n",
       "      <td>593712.747296</td>\n",
       "      <td>9.865152e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-31</th>\n",
       "      <td>625798.455757</td>\n",
       "      <td>1.013567e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>681605.808105</td>\n",
       "      <td>1.149237e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>726541.100000</td>\n",
       "      <td>1.204724e+06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               可支配收入_住户部门      增加值_国内合计\n",
       "1992-12-31   18569.157304  2.663810e+04\n",
       "1993-12-31   22916.033830  3.463440e+04\n",
       "1994-12-31   32220.436853  4.675940e+04\n",
       "1995-12-31   39863.656425  5.847810e+04\n",
       "1996-12-31   48650.470450  6.788460e+04\n",
       "1997-12-31   53411.442745  7.446260e+04\n",
       "1998-12-31   56728.456581  7.834520e+04\n",
       "1999-12-31   58768.622894  8.206750e+04\n",
       "2000-12-31   64764.455546  9.921460e+04\n",
       "2001-12-31   69691.308729  1.096552e+05\n",
       "2002-12-31   75015.702228  1.203327e+05\n",
       "2003-12-31   83012.318353  1.358228e+05\n",
       "2004-12-31   94545.642409  1.598783e+05\n",
       "2005-12-31  107217.032571  1.849374e+05\n",
       "2006-12-31  125117.580960  2.163144e+05\n",
       "2007-12-31  152265.316522  2.658103e+05\n",
       "2008-12-31  179880.320355  3.140454e+05\n",
       "2009-12-31  197488.316843  3.409028e+05\n",
       "2010-12-31  229965.430370  4.015128e+05\n",
       "2011-12-31  274930.226704  4.731041e+05\n",
       "2012-12-31  308344.771021  5.194701e+05\n",
       "2013-12-31  341749.705414  5.880188e+05\n",
       "2014-12-31  373626.512522  6.439741e+05\n",
       "2015-12-31  404897.471129  6.890521e+05\n",
       "2016-12-31  441165.522969  7.435855e+05\n",
       "2017-12-31  489176.864283  8.207543e+05\n",
       "2018-12-31  543300.943681  9.192811e+05\n",
       "2019-12-31  593712.747296  9.865152e+05\n",
       "2020-12-31  625798.455757  1.013567e+06\n",
       "2021-12-31  681605.808105  1.149237e+06\n",
       "2022-12-31  726541.100000  1.204724e+06"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "china_data = pd.read_excel('data/CHINA/中国_资金流量表_实物交易.xlsx',index_col=0, sheet_name='data')\n",
    "china_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "80ca17e1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>可支配收入_住户部门</th>\n",
       "      <th>增加值_国内合计</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1992</th>\n",
       "      <td>18569.157304</td>\n",
       "      <td>2.663810e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1993</th>\n",
       "      <td>22916.033830</td>\n",
       "      <td>3.463440e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1994</th>\n",
       "      <td>32220.436853</td>\n",
       "      <td>4.675940e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995</th>\n",
       "      <td>39863.656425</td>\n",
       "      <td>5.847810e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1996</th>\n",
       "      <td>48650.470450</td>\n",
       "      <td>6.788460e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1997</th>\n",
       "      <td>53411.442745</td>\n",
       "      <td>7.446260e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1998</th>\n",
       "      <td>56728.456581</td>\n",
       "      <td>7.834520e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999</th>\n",
       "      <td>58768.622894</td>\n",
       "      <td>8.206750e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000</th>\n",
       "      <td>64764.455546</td>\n",
       "      <td>9.921460e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001</th>\n",
       "      <td>69691.308729</td>\n",
       "      <td>1.096552e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2002</th>\n",
       "      <td>75015.702228</td>\n",
       "      <td>1.203327e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003</th>\n",
       "      <td>83012.318353</td>\n",
       "      <td>1.358228e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004</th>\n",
       "      <td>94545.642409</td>\n",
       "      <td>1.598783e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005</th>\n",
       "      <td>107217.032571</td>\n",
       "      <td>1.849374e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>125117.580960</td>\n",
       "      <td>2.163144e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td>152265.316522</td>\n",
       "      <td>2.658103e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td>179880.320355</td>\n",
       "      <td>3.140454e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td>197488.316843</td>\n",
       "      <td>3.409028e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td>229965.430370</td>\n",
       "      <td>4.015128e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td>274930.226704</td>\n",
       "      <td>4.731041e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012</th>\n",
       "      <td>308344.771021</td>\n",
       "      <td>5.194701e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013</th>\n",
       "      <td>341749.705414</td>\n",
       "      <td>5.880188e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014</th>\n",
       "      <td>373626.512522</td>\n",
       "      <td>6.439741e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015</th>\n",
       "      <td>404897.471129</td>\n",
       "      <td>6.890521e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>441165.522969</td>\n",
       "      <td>7.435855e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>489176.864283</td>\n",
       "      <td>8.207543e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>543300.943681</td>\n",
       "      <td>9.192811e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019</th>\n",
       "      <td>593712.747296</td>\n",
       "      <td>9.865152e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020</th>\n",
       "      <td>625798.455757</td>\n",
       "      <td>1.013567e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021</th>\n",
       "      <td>681605.808105</td>\n",
       "      <td>1.149237e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022</th>\n",
       "      <td>726541.100000</td>\n",
       "      <td>1.204724e+06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         可支配收入_住户部门      增加值_国内合计\n",
       "1992   18569.157304  2.663810e+04\n",
       "1993   22916.033830  3.463440e+04\n",
       "1994   32220.436853  4.675940e+04\n",
       "1995   39863.656425  5.847810e+04\n",
       "1996   48650.470450  6.788460e+04\n",
       "1997   53411.442745  7.446260e+04\n",
       "1998   56728.456581  7.834520e+04\n",
       "1999   58768.622894  8.206750e+04\n",
       "2000   64764.455546  9.921460e+04\n",
       "2001   69691.308729  1.096552e+05\n",
       "2002   75015.702228  1.203327e+05\n",
       "2003   83012.318353  1.358228e+05\n",
       "2004   94545.642409  1.598783e+05\n",
       "2005  107217.032571  1.849374e+05\n",
       "2006  125117.580960  2.163144e+05\n",
       "2007  152265.316522  2.658103e+05\n",
       "2008  179880.320355  3.140454e+05\n",
       "2009  197488.316843  3.409028e+05\n",
       "2010  229965.430370  4.015128e+05\n",
       "2011  274930.226704  4.731041e+05\n",
       "2012  308344.771021  5.194701e+05\n",
       "2013  341749.705414  5.880188e+05\n",
       "2014  373626.512522  6.439741e+05\n",
       "2015  404897.471129  6.890521e+05\n",
       "2016  441165.522969  7.435855e+05\n",
       "2017  489176.864283  8.207543e+05\n",
       "2018  543300.943681  9.192811e+05\n",
       "2019  593712.747296  9.865152e+05\n",
       "2020  625798.455757  1.013567e+06\n",
       "2021  681605.808105  1.149237e+06\n",
       "2022  726541.100000  1.204724e+06"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "china_data.index = pd.to_datetime(china_data.index)\n",
    "china_data.index = china_data.index.year\n",
    "china_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "531d38b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "text": [
          "0.70",
          "0.66",
          "0.69",
          "0.68",
          "0.72",
          "0.72",
          "0.72",
          "0.72",
          "0.65",
          "0.64",
          "0.62",
          "0.61",
          "0.59",
          "0.58",
          "0.58",
          "0.57",
          "0.57",
          "0.58",
          "0.57",
          "0.58",
          "0.59",
          "0.58",
          "0.58",
          "0.59",
          "0.59",
          "0.60",
          "0.59",
          "0.60",
          "0.62",
          "0.59",
          "0.60"
         ],
         "textposition": "auto",
         "type": "bar",
         "x": [
          1992,
          1993,
          1994,
          1995,
          1996,
          1997,
          1998,
          1999,
          2000,
          2001,
          2002,
          2003,
          2004,
          2005,
          2006,
          2007,
          2008,
          2009,
          2010,
          2011,
          2012,
          2013,
          2014,
          2015,
          2016,
          2017,
          2018,
          2019,
          2020,
          2021,
          2022
         ],
         "y": [
          0.6970901567303975,
          0.6616552857852308,
          0.6890686547089997,
          0.6816852193385217,
          0.7166643163545192,
          0.7172922076988985,
          0.7240833718083558,
          0.7161010496725256,
          0.6527714222100376,
          0.6355495109123872,
          0.6234024685559286,
          0.6111810266980212,
          0.591360068308207,
          0.5797477014979123,
          0.5784061577037868,
          0.5728345234251645,
          0.5727844456725046,
          0.5793097529354408,
          0.5727474450876784,
          0.5811199410531424,
          0.5935755898578186,
          0.581188399782456,
          0.5801887257919224,
          0.5876151761659242,
          0.5932949512450149,
          0.5960088960642667,
          0.5910063053430735,
          0.6018282799005985,
          0.6174218915765133,
          0.5930942188518923,
          0.6030768280327994
         ]
        }
       ],
       "layout": {
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "示例柱状图"
        },
        "xaxis": {
         "title": {
          "text": "类别"
         }
        },
        "yaxis": {
         "title": {
          "text": "数值"
         }
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ratio_dpi_gdp_china = ratio_of_series(china_data['可支配收入_住户部门'], china_data['增加值_国内合计'])\n",
    "fg = go.Figure(data=[go.Bar(\n",
    "    x=ratio_dpi_gdp_china.index,\n",
    "    y=ratio_dpi_gdp_china.values,\n",
    "    text=[f\"{s:.2f}\" for s in ratio_dpi_gdp_china.values],  # 显示数值在柱子上\n",
    "    textposition='auto'\n",
    ")])\n",
    "\n",
    "# 设置图表标题和坐标轴标签\n",
    "fg.update_layout(\n",
    "    title='示例柱状图',\n",
    "    xaxis_title='类别',\n",
    "    yaxis_title='数值'\n",
    ")\n",
    "# 显示图表\n",
    "fg"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb282fe3",
   "metadata": {},
   "source": [
    "# 中美两国比较"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "dbacc996",
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_common_index_bars(series1, series2):\n",
    "    \"\"\"\n",
    "    绘制两个序列共有的 index 对应的值的柱状图。\n",
    "\n",
    "    参数:\n",
    "    series1 (pandas.Series): 第一个序列。\n",
    "    series2 (pandas.Series): 第二个序列。\n",
    "    \"\"\"\n",
    "    # 找出两个序列共有的 index\n",
    "    common_index = series1.index.intersection(series2.index)\n",
    "    # 提取共有的 index 对应的值\n",
    "    common_series1 = series1[common_index]\n",
    "    common_series2 = series2[common_index]\n",
    "\n",
    "    # 创建柱状图\n",
    "    fig = go.Figure(data=[\n",
    "        go.Bar(\n",
    "            x=common_index,\n",
    "            y=common_series1.values,\n",
    "            name=series1.name if series1.name else 'Series 1',\n",
    "            text=[f\"{s:.2f}\" for s in common_series1.values],\n",
    "            textposition='auto'\n",
    "        ),\n",
    "        go.Bar(\n",
    "            x=common_index,\n",
    "            y=common_series2.values,\n",
    "            name=series2.name if series2.name else 'Series 2',\n",
    "            text=[f\"{s:.2f}\" for s in common_series2.values],\n",
    "            textposition='auto'\n",
    "        )\n",
    "    ])\n",
    "\n",
    "    # 设置图表标题和坐标轴标签\n",
    "    fig.update_layout(\n",
    "        title='共有的 index 对应的柱状图',\n",
    "        xaxis_title='Index',\n",
    "        yaxis_title='Value'\n",
    "    )\n",
    "\n",
    "    return fig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "0677414d",
   "metadata": {},
   "outputs": [],
   "source": [
    "ratio_dpi_gdp.name = '美国'\n",
    "ratio_dpi_gdp_china.name = '中国'\n",
    "ff = plot_common_index_bars(ratio_dpi_gdp, ratio_dpi_gdp_china)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "78cf8d84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "name": "美国",
         "text": [
          "0.74",
          "0.73",
          "0.72",
          "0.72",
          "0.72",
          "0.72",
          "0.72",
          "0.71",
          "0.72",
          "0.73",
          "0.74",
          "0.74",
          "0.73",
          "0.72",
          "0.72",
          "0.72",
          "0.74",
          "0.75",
          "0.75",
          "0.76",
          "0.76",
          "0.73",
          "0.74",
          "0.74",
          "0.74",
          "0.75",
          "0.75",
          "0.75",
          "0.81",
          "0.79",
          "0.72"
         ],
         "textposition": "auto",
         "type": "bar",
         "x": [
          1992,
          1993,
          1994,
          1995,
          1996,
          1997,
          1998,
          1999,
          2000,
          2001,
          2002,
          2003,
          2004,
          2005,
          2006,
          2007,
          2008,
          2009,
          2010,
          2011,
          2012,
          2013,
          2014,
          2015,
          2016,
          2017,
          2018,
          2019,
          2020,
          2021,
          2022
         ],
         "y": [
          0.7368789145769741,
          0.7296115259982594,
          0.7201403897531434,
          0.7244914920909653,
          0.7220379155064767,
          0.7160715911288992,
          0.7233862106575936,
          0.7129644773839002,
          0.7204176418606454,
          0.7327673117695901,
          0.7409456302164451,
          0.7400387586631152,
          0.733977080351411,
          0.7158147852202862,
          0.7198423451740448,
          0.7212572848737736,
          0.7392198508560854,
          0.7537815518849729,
          0.7521455564414782,
          0.7600050680359467,
          0.7634006748300055,
          0.7340475984584331,
          0.7382041085462286,
          0.7397022471890664,
          0.740704471653616,
          0.7451478833881612,
          0.7481432835723592,
          0.7504412975780257,
          0.813651529924241,
          0.7902649829928698,
          0.7245777890098429
         ]
        },
        {
         "name": "中国",
         "text": [
          "0.70",
          "0.66",
          "0.69",
          "0.68",
          "0.72",
          "0.72",
          "0.72",
          "0.72",
          "0.65",
          "0.64",
          "0.62",
          "0.61",
          "0.59",
          "0.58",
          "0.58",
          "0.57",
          "0.57",
          "0.58",
          "0.57",
          "0.58",
          "0.59",
          "0.58",
          "0.58",
          "0.59",
          "0.59",
          "0.60",
          "0.59",
          "0.60",
          "0.62",
          "0.59",
          "0.60"
         ],
         "textposition": "auto",
         "type": "bar",
         "x": [
          1992,
          1993,
          1994,
          1995,
          1996,
          1997,
          1998,
          1999,
          2000,
          2001,
          2002,
          2003,
          2004,
          2005,
          2006,
          2007,
          2008,
          2009,
          2010,
          2011,
          2012,
          2013,
          2014,
          2015,
          2016,
          2017,
          2018,
          2019,
          2020,
          2021,
          2022
         ],
         "y": [
          0.6970901567303975,
          0.6616552857852308,
          0.6890686547089997,
          0.6816852193385217,
          0.7166643163545192,
          0.7172922076988985,
          0.7240833718083558,
          0.7161010496725256,
          0.6527714222100376,
          0.6355495109123872,
          0.6234024685559286,
          0.6111810266980212,
          0.591360068308207,
          0.5797477014979123,
          0.5784061577037868,
          0.5728345234251645,
          0.5727844456725046,
          0.5793097529354408,
          0.5727474450876784,
          0.5811199410531424,
          0.5935755898578186,
          0.581188399782456,
          0.5801887257919224,
          0.5876151761659242,
          0.5932949512450149,
          0.5960088960642667,
          0.5910063053430735,
          0.6018282799005985,
          0.6174218915765133,
          0.5930942188518923,
          0.6030768280327994
         ]
        }
       ],
       "layout": {
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "共有的 index 对应的柱状图"
        },
        "xaxis": {
         "title": {
          "text": "Index"
         }
        },
        "yaxis": {
         "title": {
          "text": "Value"
         }
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ff"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "e3c32a79",
   "metadata": {},
   "outputs": [],
   "source": [
    "ff.write_html('中美可支配收入占GDOP的比例.html')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "gradioweb",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
